feat: sync with exam service on course publish#31015
Conversation
b272620 to
8f7c7ac
Compare
| User = get_user_model() | ||
|
|
||
|
|
||
| def register_exams(course_key): |
There was a problem hiding this comment.
there is some intentional code duplication between this function and the edx-proctoring register_special_exams. I think it would be messier to try to reuse some of these statements when these two integrations may evolve differently.
| LOGGER.info('Attempting to register exams for course %s', course_key_str) | ||
|
|
||
| # Call the appropriate handler for either the exams IDA or the edx-proctoring plugin | ||
| register_exams_handler = register_exams if exams_ida_enabled(course_key) else register_exams_legacy |
There was a problem hiding this comment.
I like the naming and structure here, it is very clear about what is what in very little space
|
|
||
| try: | ||
| _patch_course_exams(exams_list, str(course_key)) | ||
| log.info(f'Successfully registered {locations} with exam service') |
There was a problem hiding this comment.
are the locations useful in this log or too detailed? what about the course key?
There was a problem hiding this comment.
It doesn't actually come out to messy since I wouldn't expect a large number of exams in one course Successfully registered ['block-v1:edX+DemoX+Demo_Course+type@sequential+block@00a45f2d4cc54b07a172183a1834d710', 'block-v1:edX+DemoX+Demo_Course+type@sequential+block@00a45f2d4cc54b07a172183a1834d71123'] with exam service
But you might have a point, I'm not sure if this is actually more useful than just the course key 🤔
varshamenon4
left a comment
There was a problem hiding this comment.
Looks great! Approving as I just had some clarifying questions. :)
| } | ||
| ) | ||
|
|
||
| # filter out any potential dangling sequences |
There was a problem hiding this comment.
[question]: @zacharis278, could you clarify what is happening here and what is meant by "dangling sequences"? Thanks!
There was a problem hiding this comment.
A dangling sequence is one that is part of the course but has no relationship back up to the course block. If you look at the test for this it's a kind of easier to see. For example, the section that is a parent of the sequence is deleted.
cms/djangoapps/contentstore/exams.py
Outdated
| log.info(msg) | ||
| locations.append(location) | ||
|
|
||
| if timed_exam.is_proctored_exam: |
There was a problem hiding this comment.
[question/suggestion]: Could there be any potential issues in the future with using conditional statements like this and also with defining the exam types here? Is there an enum/class/other data type that could be better used here?
There was a problem hiding this comment.
oh good observation, my thinking is we would eventually move away from using these independent variables and just directly set exam type. They don't serve any purpose in the LMS/CMS other than backwards compatibility. Maybe I should move this into a function just in case it needs to be referenced elsewhere.
| return client | ||
|
|
||
|
|
||
| def _patch_course_exams(exams_list, course_id): |
There was a problem hiding this comment.
I like that you've created a helper method for this! Looks good.
| LOGGER.info('Attempting to register exams for course %s', course_key_str) | ||
|
|
||
| # Call the appropriate handler for either the exams IDA or the edx-proctoring plugin | ||
| register_exams_handler = register_exams if exams_ida_enabled(course_key) else register_exams_legacy |
| @override_waffle_flag(EXAMS_IDA, active=True) | ||
| @patch.dict('django.conf.settings.FEATURES', {'ENABLE_SPECIAL_EXAMS': True}) | ||
| @patch('cms.djangoapps.contentstore.exams._patch_course_exams') | ||
| class TestExamService(ModuleStoreTestCase): |
06b3c2b to
379b9e4
Compare
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
|
EdX Release Notice: This PR has been deployed to the production environment. |
| """ | ||
| Test for syncing exams to the exam service | ||
| """ | ||
| MODULESTORE = TEST_DATA_MONGO_AMNESTY_MODULESTORE |
There was a problem hiding this comment.
@zacharis278: I ran across this code while reviewing #31134
Please note that this is testing against Old Mongo, the Modulestore that's been deprecated for years and is currently in the process of being removed. Please use TEST_DATA_SPLIT_MODULESTORE (I believe it will default to this without the override line here).
There was a problem hiding this comment.
@ormsbee oh weird, yeah looks like I just blindly copied this from the older proctoring tests. Is cleaning this up blocking anything?
There was a problem hiding this comment.
@zacharis278: That PR I linked to above is removing features from Old Mongo that this test depends on. In general, the team has tried to convert Old Mongo modulestore based tests to Split Modulestore based ones. Sometimes, a straightforward conversion fails (like this one, apparently). The policy we've adopted for tests that look useful but have never worked in Split Mongo is to mark them as @skip("OldMongo Deprecation") and review them later to see if they're worth keeping.
I realize this is new, actively developed functionality, and not some old test written 8+ years ago. I really hope it's a straightforward change for you folks. But we've been as loud as we could for a long while that Old Mongo is going away. So fixing this is non-blocking in the sense that we can land #31134 without it, but we would do that by disabling the test.
In terms of the timing, I don't think we'll merge before next week. It's a big PR that touches a bunch of old functionality, some of which I had forgotten even existed. I've been looking over for hours and I'm still less than halfway through it. Even assuming very quick turnaround on review cycles, I wouldn't expect the reviews to be done before Friday, and we wouldn't release something like this that close to the weekend.
There was a problem hiding this comment.
If there's proctoring code that relies on using Old Mongo, that should definitely get looked at as well. There was at least one that was a straightforward conversion (cms/djangoapps/contentstore/tests/test_proctoring.py), but I don't know if that was the one you were referring to.
Description
MST-1526
Call into the exam service instead of the edx-proctoring plugin on course publish. This feature is currently behind the
course_apps.exams_idacourse waffle flag.configuration PR: https://github.com/edx/edx-internal/pull/7120